home *** CD-ROM | disk | FTP | other *** search
- From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
- Date: Fri, 18 Feb 94 10:36:38 +0100
- Message-Id: <9402180936.AA05169@issan.informatik.uni-dortmund.de>
- To: mint@atari.archive.umich.edu
- Subject: MiNT 1.10: bugs in nalloc/nfree/kmalloc
-
- nalloc2.c:
- - nfree: decrement fb over header before testing for NKMAGIC. This
- worked before by pure coincidence, because kmalloc always stashes
- NKMAGIC into the first two longs of the memory returned by nalloc.
- - nfree: when looking for the arena compare with the correct bounds.
- - nalloc: always put NKMAGIC into the b_next field of the header so
- that nfree can find it.
-
- util.c:
- - kmalloc: the size of the region passed to nalloc_arena_add is really
- two longs smaller!
-
- --- orig/nalloc2.c Wed Feb 9 21:22:52 1994
- +++ nalloc2.c Thu Feb 17 21:40:36 1994
- @@ -115,13 +115,13 @@
- b->b_next = mb->b_next;
- *q = b;
- mb->b_size = size;
- - mb->b_next = (struct block *)NKMAGIC;
- }
- else {
- /* not big enough to cut: unlink this from free list */
- NALLOC_DEBUG('w');
- *q = mb->b_next;
- }
- + mb->b_next = (struct block *)NKMAGIC;
- return (void *)(mb+1);
- }
- }
- @@ -186,17 +186,18 @@
- struct block *fb = (struct block *)start;
-
- NALLOC_DEBUG('F');
- + /* set fb (and b) to header start */
- + b = --fb;
- +
- if (fb->b_next != (struct block *)NKMAGIC) {
- FATAL("nfree: block %lx not allocated by nalloc!",fb);
- }
-
- - /* set fb (and b) to header start */
- - b = --fb;
- -
- /* the arena this block lives in */
- for (a = *(qa = &a_first); a; a = *(qa = &a->a_next)) {
- - if ((unsigned long)b > (unsigned long)a &&
- - (unsigned long)b < (((unsigned long)a) + a->a_size)) goto found;
- + if ((unsigned long)b >= (unsigned long)(a+1) &&
- + (unsigned long)b < (((unsigned long)(a+1)) + a->a_size))
- + goto found;
- }
- FATAL("nfree: block %lx not in any arena!",fb);
-
- --- orig/util.c Wed Sep 15 02:44:12 1993
- +++ util.c Thu Feb 17 20:50:10 1994
- @@ -158,7 +158,7 @@
- lp = (long *)m->loc;
- *lp++ = (long)KMAGIC;
- *lp++ = (long)m;
- -#if 0
- +#if 1
- nalloc_arena_add((void *)lp,KERMEM_SIZE - 2*SIZEOF(long));
- #else
- nalloc_arena_add((void *)lp,KERMEM_SIZE);
-